#include "LCDRange.h"
#include <QLCDNumber>
#include <QVBoxLayout>
#include <QFont>
#include <QPalette>
#include <QColor>

LCDRange::LCDRange(QWidget *parent,const char *name){
	QLCDNumber *lcd=new QLCDNumber(2,this);
	QFont font("Helvetica",18,QFont::Bold);
	lcd->setFont(font);
	//lcd->setSegmentStyle(QLCDNumber::Filled);
	lcd->setSegmentStyle(QLCDNumber::Flat);
	//lcd->setSegmentStyle(QLCDNumber::Outline);
	
    QSlider *slider=new QSlider(Qt::Horizontal,this);
    slider->setRange(0,99);
    slider->setValue(0);
    connect(slider,SIGNAL(valueChanged(int)),lcd,SLOT(display(int)));
    connect(slider,SIGNAL(valueChanged(int)),SIGNAL(valueChanged(int)));

	QVBoxLayout* layout=new QVBoxLayout();
	
	layout->addWidget(lcd);
	layout->addWidget(slider);
	
	this->setLayout(layout);
	
	QPalette palette;
	palette.setColor(lcd->backgroundRole(),Qt::gray);
	palette.setColor(lcd->foregroundRole(),Qt::black);
	lcd->setPalette(palette);
	
	this->setPalette(palette);
	this->setFont(font);
	this->setWindowTitle(tr("lcd demo"));
}


int LCDRange::value() const{
    return slider->value();
}

void LCDRange::setValue(int value){
    slider->setValue(value);
}

